package com.loveprigrammer.eternity.task.work;

import com.loveprogrammer.eternity.model.mission.MissionState;

/**
 * @version 1.0.0
 * @description: 执行结果的封装
 * @author: eric
 * @date: 2022-09-15 18:03
 **/
public class WorkResult<V> {

    private V result;

    private MissionState taskState;

    private Exception ex;

    public WorkResult(V result, MissionState taskState) {
        this.result = result;
        this.taskState = taskState;
        this.ex = null;
    }

    public WorkResult(V result, MissionState taskState, Exception ex) {
        this.result = result;
        this.taskState = taskState;
        this.ex = ex;
    }

    public static <V> WorkResult<V> defaultResult(){
        return new WorkResult<>(null, MissionState.canAccept);
    }

    @Override
    public String toString() {
        return "WorkResult{" +
                "result=" + result +
                ", taskState=" + taskState +
                ", ex=" + ex +
                '}';
    }

    public V getResult() {
        return result;
    }

    public void setResult(V result) {
        this.result = result;
    }

    public MissionState getTaskState() {
        return taskState;
    }

    public void setTaskState(MissionState taskState) {
        this.taskState = taskState;
    }

    public Exception getEx() {
        return ex;
    }

    public void setEx(Exception ex) {
        this.ex = ex;
    }
}
